package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Pkwb;
import com.gw.detail.service.IPkwbService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 乘用车外部损坏Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/pkwb")
public class PkwbController extends BaseController
{
    @Autowired
    private IPkwbService pkwbService;

    /**
     * 查询乘用车外部损坏列表
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pkwb pkwb)
    {
        startPage();
        List<Pkwb> list = pkwbService.selectPkwbList(pkwb);
        return getDataTable(list);
    }

    /**
     * 导出乘用车外部损坏列表
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:export')")
    @Log(title = "乘用车外部损坏", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Pkwb pkwb)
    {
        List<Pkwb> list = pkwbService.selectPkwbList(pkwb);
        ExcelUtil<Pkwb> util = new ExcelUtil<Pkwb>(Pkwb.class);
        return util.exportExcel(list, "乘用车外部损坏数据");
    }

    /**
     * 获取乘用车外部损坏详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pkwbService.selectPkwbById(id));
    }

    /**
     * 新增乘用车外部损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:add')")
    @Log(title = "乘用车外部损坏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pkwb pkwb)
    {
        return toAjax(pkwbService.insertPkwb(pkwb));
    }

    /**
     * 修改乘用车外部损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:edit')")
    @Log(title = "乘用车外部损坏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pkwb pkwb)
    {
        return toAjax(pkwbService.updatePkwb(pkwb));
    }

    /**
     * 删除乘用车外部损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:pkwb:remove')")
    @Log(title = "乘用车外部损坏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pkwbService.deletePkwbByIds(ids));
    }
}
